package cn.springboot.chapter04advice.controller;

import cn.springboot.chapter04advice.beans.Author;
import cn.springboot.chapter04advice.beans.Book;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class Hello {
    @GetMapping("/hello")
    public void hello(Model model) {
        Map<String, Object> map = model.asMap();
        for (String key :
                map.keySet()) {
            Object value=map.get(key);
            System.out.println(key+">>>>"+value);
        }
    }
    @GetMapping("/book")
    public  String  book(@ModelAttribute("b") Book book,@ModelAttribute("a")  Author author){
        return book.toString()+">>>"+author.toString();
    }
}
